package com.android.delivery.util;

import android.media.AudioManager;
import android.media.SoundPool;

import com.android.delivery.App;
import com.android.delivery.R;

/**
 * Desc:
 * <p>
 * Author: [李豫]
 * Date: 2021-06-21
 * Copyright: Copyright (c) 2010-2021
 * Updater:
 * Update Time:
 * Update Comments:
 */
public class SoundUtil {
    private SoundPool mTickSoundPool;
    private static SoundUtil mInstance;

    public static SoundUtil getInstance() {
        synchronized (SoundUtil.class) {
            if (mInstance == null) {
                mInstance = new SoundUtil();
            }
            return mInstance;
        }
    }

    public SoundUtil() {
    }

    public void init(){
        if (mTickSoundPool == null) {
            mTickSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 5);
            mTickSoundPool.load(App.Companion.getInstance().getApplicationContext(), R.raw.notification, 1);
        }
    }

    public void playTick() {
        if (mTickSoundPool == null) {
            mTickSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 5);
            mTickSoundPool.load(App.Companion.getInstance().getApplicationContext(), R.raw.notification, 1);
        }
        mTickSoundPool.play(1, 1, 1, 0, 0, 1);
    }
}
